<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑商品分类</title>
    <link rel="stylesheet" href="__PEAR__/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

                  <div class="layui-form-item">
				    <label class="layui-form-label">父类</label>
				    <div class="layui-input-inline">
				     <label class="layui-form-label" style="width:100px;text-align:left;">{present name="cls_parent" }{$cls_parent.item_clsno}  {$cls_parent.item_clsname} {/present}</label>
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">分类编码</label>
				    <div class="layui-input-inline">
				      <input type="text" name="item_clsno" value="{$one['item_clsno']}" required  lay-verify="required" placeholder="请输入唯一的分类编码" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">分类名称</label>
				    <div class="layui-input-inline">
				      <input type="text" name="item_clsname" value="{$one['item_clsname']}" required  lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  <div class="layui-form-item">
						<label class="layui-form-label">排序</label>
						<div class="layui-input-inline">
							<input type="text" name="orderby" value="{$one['orderby']}" placeholder="请输入数字" autocomplete="off" class="layui-input">
						</div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">是否显示</label>
				    <div class="layui-input-inline">
				      <input type="radio" name="display_flag"  value="1" {if condition="$one['display_flag'] eq 1 OR empty($one)"} checked="checked"{/if} title="显示" >
						<input type="radio" name="display_flag" value="0" {if condition="$one['display_flag'] eq 0 AND !empty($one)"} checked="checked"{/if} title="隐藏">
				    </div>
				  </div>
				  
				  <input name="cls_parent" type="hidden" value="{$one?$one['cls_parent']:$parent}"/>
				  <input name="modify" type="hidden" value="{$one?1:0}"/>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="type-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__PEAR__/component/pear/pear.js"></script>
<script>
layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;
    var path="/{$MODULE_NAME}/Itemcls";
	var _url="/clspost";	
	var tree_path="/{$MODULE_NAME}/imsheet/Jsondata/ItemClass";
    form.on('submit(type-save)', function(data){
        $.ajax({
            url:path+_url,
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("itemscls-table",{
							where:{}
						});
                        var treeHeight=parent.getParentWinHeight($)-25;
                        parent.rebuildTree(parent.layui.dtree,"clsTree",tree_path,treeHeight);
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>